import { defHttp } from '@/utils/http';
import { exc, root } from '../apiRoot';
import type { IResData, IQuery } from '../indexTypes';
import type { IQuestionParams, IQuestionResData, IAnswerSubmitParams, IFeedbackParams } from './types';

const Api = {
  questionInfo: 'app/form/question/info',
  feedbackSubmit: 'app/form/question/feedback/submit',
  answerSubmit: 'app/form/question/answer/submit'
};
/**
 * 获取问卷表单
 * @export
 * @param {IQuestionParams} data
 * @return {*}  {Promise<IQuestionResData>}
 */
export function questionInfo(data: IQuestionParams): Promise<IQuestionResData> {
  const { id } = data;
  return defHttp.get({
    url: Api.questionInfo + `/${id}`
  });
}

/**
 * 提交问卷
 * @export
 * @param {IAnswerSubmitParams} data 
 * @returns {*} {Promise<any>}
 */
export function answerSubmit(data: IAnswerSubmitParams): Promise<any> {
  return defHttp.post({
    url: Api.answerSubmit,
    data
  })
}

/**
 * 提交问卷反馈
 * @export
 * @param {IFeedbackParams} data  
 * @returns {*} {Promise<any>}
 */
export function feedbackSubmit(data: IFeedbackParams): Promise<any> {
  return defHttp.post({
    url: Api.feedbackSubmit,
    data
  });
}
